import { hasPermission } from '../manager/PermissionManager'
import { addDomClass, removeDomClass } from '../utils/normalUtils'

export const hasPerm = {
    install(Vue:any) {
        Vue.directive('has', {
            mounted(el:any, binding:any, vnode:any) {
                if (!hasPermission(binding.value)) {
                    el.remove()
                }
            }
        })
        Vue.directive('enabled', {
            mounted(el:any, binding:any, vnode:any) {
                if (!hasPermission(binding.value)) addDomClass(el, 'z_dom_disabled_gl')
                else removeDomClass(el, 'z_dom_disabled_gl')
            }
        })
    }
}
export default hasPerm
